﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace TuongLai_Schools
{
    public class cls_DM_Dotuoihocsinh
    {
        public DataTable GetAll_Dotuoihocsinh()
        {
            DbAccess db = new DbAccess();
            db.CreateNewSqlCommand_Text();
            DataTable dataTable = db.ExecuteDataTable("Select DoTuoiHocSinhID,TenDoTuoiHocSinh,GhiChu,isChangeable from DM_DoTuoiHocSinh");
            return dataTable;
        }
        public bool Insert(clsDM_Dotuoihocsinh obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@DoTuoiHocSinhID", obj.DoTuoiHocSinhID);
                db.AddParameter("@TenDoTuoiHocSinh", obj.TenDoTuoiHocSinh);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("insert into DM_DoTuoiHocSinh(TenDoTuoiHocSinh,GhiChu,isChangeable) values(N'" + obj.TenDoTuoiHocSinh + "',N'" + obj.GhiChu + "','" + obj.isChangeable + "')");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool update(clsDM_Dotuoihocsinh obj)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@DoTuoiHocSinhID", obj.DoTuoiHocSinhID);
                db.AddParameter("@TenDoTuoiHocSinh", obj.TenDoTuoiHocSinh);
                db.AddParameter("@GhiChu", obj.GhiChu);
                db.AddParameter("@isChangeable", obj.isChangeable);
                db.ExecuteNonQuery("update DM_DoTuoiHocSinh set TenDoTuoiHOcSinh=N'" + obj.TenDoTuoiHocSinh + "',GhiChu=N'" + obj.GhiChu + "',isChangeable='" + obj.isChangeable + "' where DoTuoiHocSinhID='" + obj.DoTuoiHocSinhID + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }
        public bool delete(int Dotuoihocsinhid)
        {
            try
            {
                DbAccess db = new DbAccess();
                db.CreateNewSqlCommand_Text();
                db.AddParameter("@DoTuoiHocSinhID", Dotuoihocsinhid);
                db.ExecuteNonQuery("delete DM_DoTuoiHocSinh where DoTuoiHocSinhID='" + Dotuoihocsinhid + "'");
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
